<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        ul {
            height: 40px;
            margin: 30px auto;
            border-bottom: 3px solid pink;
            width: 1000px;
            position: relative;
            list-style: none;
        }

        li {
            float: left;
            width: 100px;height: 100%;
            display: flex;justify-content: center;
            cursor: pointer;align-items: center;
        }
        ul>p{
            width: 100px;height: 40px;
            background-color: skyblue;
            position: absolute;top: 0;left: 0;
            display: flex;
            justify-content: center;align-items: center;
            border-bottom: 2px solid red;
            cursor: pointer;
        }
    </style>
</head>

<body>
    <ul>
        <li>我是1选项</li>
        <li>我是2选项</li>
        <li>我是3选项</li>
        <li>我是4选项</li>
        <li>我是5选项</li>
        <li>我是6选项</li>
        <li>我是7选项</li>
        <li>我是8选项</li>
        <li>我是9选项</li>
        <p>我是1选项</p>
    </ul>
</body>

</html>
<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script>
    let flag = false
    $('ul').on('mouseenter','li',function(){
        // console.log(this);
        $('ul>p').stop().animate({left:$(this).position().left},200).text($(this).text())
    })
    $('ul>p').click(function(){
        flag = true
    })
    $('ul').mouseleave(function(){
        if(flag){
            flag = false
            return
        }
        $('ul>p').animate({left:0},300).text($('ul li').eq(0).text())
    })
    
</script>